#include "QRWCreateCurveWidget.h"
#include <TopoDS.hxx>
#include "Core/RWTools.h"
#include <TopoDS_Edge.hxx>
#include "Core/MainWindow.h"

QRWCreateCurveWidget::QRWCreateCurveWidget(MainWindow* inMainWindow, ShapeOperation* inOperation, QWidget* parent)
	: CreateBaseWidget(inMainWindow, inOperation, parent)
{
	connect(m_mainWindow, &MainWindow::OnSelectedSubShapes, this, &QRWCreateCurveWidget::OnSelectedSubShapes);
}

QRWCreateCurveWidget::~QRWCreateCurveWidget()
{
}

void QRWCreateCurveWidget::OnSelectedSubShapes(QIVtkSelectionPipeline* actor)
{
	const std::vector<std::reference_wrapper<const TopoDS_Shape>>& selectShapes = m_mainWindow->GetSelectedShapes();
	if (selectShapes.empty())
	{
		return;
	}

	const TopoDS_Shape& selectedShape = selectShapes.back();
	// 选取的不是边
	if (selectedShape.ShapeType() != TopAbs_EDGE)
	{
		return;
	}

	TopoDS_Edge selectedEdge = TopoDS::Edge(selectedShape);
	OnPickDirection(GetEdgeDirection(selectedEdge));
}

void QRWCreateCurveWidget::Reset()
{
	focusIndex = 0;
	bBatchChange = false;
}
